package com.example.yjhindex.controller;

import com.example.yjhindex.entity.Article;
import com.example.yjhindex.service.ArticleService;
import com.yc.yjh.bean.UploadProperties;
import com.yc.yjh.controller.UploadController;
import com.yc.yjh.entity.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @RequestMapping("/all")
    public Result selectArticleByPages(@RequestParam("page")int page,@RequestParam("size") int size){
        final List<Article> articles = articleService.queryAllArticle(page, size);
        System.out.println("page = " + page);
        System.out.println("size = " + size);
        return Result.success("OK",articles);
    }

    @RequestMapping("/one")
    public Result selectById(String id){
        return Result.success("OK",articleService.getArticleById(id));
    }
}
